<?php

use think\Request;

// 验证访问方式
function checkMethod($method)
{
    switch ($method) {
        case 'post':
            if (!Request::instance()->isPost()) {
                $this->redirect('',url('admin/Error/notFound'));
                return;
            }
            break;
        case 'ajax':
            if (!Request::instance()->isAjax()) {
                $this->redirect('',url('admin/Error/notFound'));
                return;
            }
            break;
        case 'delete':
            if (!Request::instance()->isDelete()) {
                $this->redirect('',url('admin/Error/notFound'));
                return;
            }
            break;
        case 'put':
            if (!Request::instance()->isPut()) {
                $this->redirect('',url('admin/Error/notFound'));
                return;
            }
            break;
    }
}
